package com.smart_environmental_protection.controller;

import com.smart_environmental_protection.pojo.Content;
import com.smart_environmental_protection.pojo.Cpnlist;
import com.smart_environmental_protection.pojo.Notice;
import com.smart_environmental_protection.service.CplistService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class CpnlistController {
    @Autowired
    private CplistService cplistService;

    @GetMapping("/system/company/list")

    public Map<String,Object> CList(){
        Map map=new HashMap<String,Object>();
        List<Cpnlist> cpnlistList=cplistService.CList();

        if (cpnlistList!=null){ map.put("success",true);
            map.put("msg","成功");
            map.put("code",200);
            map.put("rows",cpnlistList);



        }else {
            map.put("success",false);
            map.put("msg","失败");
        }
        return map;
    }
    @GetMapping(value = "/system/company/{id}")


    public Map<String,Object> getCpnById(@PathVariable Integer id){

        Map map=new HashMap<String,Object>();
        Cpnlist cpnlist=cplistService.getCpnById(id);

        if (cpnlist!=null){
            map.put("success",true);
            map.put("code",200);
            map.put("msg","成功");
            map.put("data",cpnlist);



        }else {
            map.put("success",false);
            map.put("msg","失败");
        }
        return map;
    }


}
